import { request } from "@/utils/http";
import { DoctorsResponse, GetDepartmentResponse, GetDoctorsParams, GetHospitalListParams, GetHospitalListResponse, GetHospitalShowResponse, GetScheduleParams, GetScheduleResponse, ProvinceResponse } from "./model/hospitalList";

//声明函数获取所有的省份
export function reqGetProvinces(){
  return request.get<any, ProvinceResponse>('/admin/cmn/dict/findByDictCode/province');
}

//声明函数获取市区和县的信息
export function reqGetCityOrDistrict(id: number){
  return request.get<any, ProvinceResponse>(`/admin/cmn/dict/findByParentId/${id}`);
}

//声明函数获取所有的医院类型
export function reqGetHospitalType(){
  return request.get<any, ProvinceResponse>('/admin/cmn/dict/findByDictCode/hostype');
}

//声明函数获取医院列表数据  {page: 1, limit: 5, hosname: 'xxx', hoscode: 'xxx'}
export function reqGetHospitalList({page, limit, ...args}: GetHospitalListParams){
  // console.log(args);
  return request.get<any, GetHospitalListResponse>(`/admin/hosp/hospital/${page}/${limit}`, {
    //设置其他的 query 参数
    params: args
  })
}

//声明函数获取医院详情信息
export function reqGetHospitalShow(hosid: string){
  return request.get<any, GetHospitalShowResponse>(`/admin/hosp/hospital/show/${hosid}`);
}

//声明函数获取医院所有的科室
export function reqGetDepartment(hoscode: string){
  return request.get<any, GetDepartmentResponse>(`/admin/hosp/department/${hoscode}`);
}

//声明函数获取某个医院某个科室的排班计划 Schedule  Schema
export function reqGetSchedule({page, limit, hoscode, depcode}: GetScheduleParams){
  return request.get<any, GetScheduleResponse>(`/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`);
}

//声明函数获取某天排班医生的信息
export function reqGetDoctors({hoscode,depcode,workDate}: GetDoctorsParams){
  return request.get<any, DoctorsResponse>(`/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`)
}

//更新医院的上下线状态
export function reqUpdateHospitalStatus(id: string, status: number){
  return request.get<any, null>(`/admin/hosp/hospital/updateStatus/${id}/${status}`)
}